/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package acceso.util;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Timer;
import java.util.TimerTask;

/**
 *
 * @author romulogalindo
 */
public class ServiceManager {

    Timer temporizador;
    List l;
    public ServiceManager() {
        temporizador = new Timer("Acceso");
        
    }
    
    public void add_task(TimerTask task, long delay, long periodo){
        try{
            temporizador.scheduleAtFixedRate(task, delay, periodo);
        }catch(Exception ep){
            System.out.println(">"+ep.getMessage());
        }
    }
    
    public void cargar(){
        //List l =  new ArrayList();1000*1*30
        l =  new ArrayList();
        l.add(new Tarea(new Twitter_task(),0l,30000l));
    }
    
    public List get_tareas(){
        return l;
    }
    
    public void detener(){
        try{
            ((Tarea)l.get(0)).getTask().cancel();
            
            temporizador.purge();
            temporizador.cancel();
            
        }catch(Exception ep){
            System.out.println("[{"+ep.getMessage()+"}]");
        }
    }
}

